home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / XPK / Source / test / testFullPack.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-17  |  2.7 KB  |  110 lines

  1. #define NAME     "testFullPack"
  2. #define REVISION "2"
  3.  
  4. /* Programmheader
  5.  
  6.     Name:        testFullPack
  7.     Author:        SDI
  8.     Distribution:    PD
  9.     Description:    tests all packmodes with all file-sizes to 100000
  10.     Compileropts:    -
  11.     Linkeropts:    -l xpkmaster amiga
  12.  
  13.  1.0   15.05.97 : first version to find IDEA error
  14.  1.1   16.05.97 : changed output format (shorter)
  15.  1.2   17.05.97 : fixed a wrong parameter
  16. */
  17.  
  18. #include <pragma/exec_lib.h>
  19. #include <pragma/dos_lib.h>
  20. #include <pragma/xpkmaster_lib.h>
  21. #include <exec/memory.h>
  22. #include "SDI_defines.h"
  23.  
  24. struct Library        *XpkBase        = 0;
  25. ULONG            DosVersion        = 37;
  26.  
  27. #define PARAM "METHOD,START/N,PASSWORD,FILE,STEP/N"
  28.  
  29. void main(void)
  30. {
  31.   ULONG noth = 1, step = 1;
  32.   struct RDArgs    *rda;
  33.   struct args
  34.   {
  35.     STRPTR method;
  36.     ULONG *start;
  37.     STRPTR password;
  38.     STRPTR file;
  39.     ULONG *step;
  40.   } args = {"IDEA", 0, "TestPwd", "testFullPack.out", 0};
  41.  
  42.   args.start = ¬h;
  43.   args.step = &step;
  44.  
  45.   if((rda = ReadArgs(PARAM, (LONG *) &args, 0)))
  46.   {
  47.     if((XpkBase = OpenLibrary(XPKNAME, 0)))
  48.     {
  49.       STRPTR ibuf;
  50.  
  51.       if((ibuf = (STRPTR) AllocMem(100000, MEMF_CLEAR)))
  52.       {
  53.         STRPTR obuf;
  54.  
  55.         if((obuf = (STRPTR) AllocMem(200000, MEMF_ANY)))
  56.         {
  57.           ULONG fh;
  58.  
  59.       if((fh = Open(args.file, MODE_READWRITE)))
  60.           {
  61.             ULONG i, j, olen;
  62.             LONG err;
  63.  
  64.         Seek(fh, 0, OFFSET_END);
  65.  
  66.         for(i = 0; i < 100000; ++i)
  67.           ibuf[i] = i;
  68.  
  69.             for(i = *args.start; !CTRL_C && i <= 100000; i += *args.step)
  70.             {
  71.               Printf("%6ld: ", i);
  72.               FPrintf(fh, "%6ld: ", i);
  73.               for(j = 0; !CTRL_C && j <= 100; ++j)
  74.               {
  75.                 if((err = XpkPackTags(XPK_InBuf, ibuf, XPK_InLen, i,
  76.                   XPK_PackMethod, args.method, XPK_OutBuf, obuf,
  77.                   XPK_OutBufLen, 200000, XPK_GetOutLen, &olen, XPK_Password,
  78.                   args.password, XPK_PackMode, j, TAG_DONE)))
  79.                   {
  80.                     Printf("p%03ld(%02ld), ", j, -err);
  81.                     FPrintf(fh,"p%03ld(%02ld), ", j, -err);
  82.                   }
  83.                 else if((err = XpkUnpackTags(XPK_InBuf, obuf, XPK_InLen, olen,
  84.                   XPK_OutName, "NIL:", XPK_Password, args.password, TAG_DONE)))
  85.                   {
  86.                     Printf("u%03ld(%02ld), ", j, -err);
  87.                     FPrintf(fh,"u%03ld(%02ld), ", j, -err);
  88.                   }
  89.               }
  90.               if(CTRL_C)
  91.               {
  92.                 Printf("\nbreak:  %03ld", j);
  93.                 FPrintf(fh, "\nbreak:  %03ld", j);
  94.               }
  95.               Printf("\n");
  96.               FPrintf(fh, "\n");
  97.             }
  98.             Close(fh);
  99.           }
  100.           FreeMem(obuf, 200000);
  101.         }
  102.         FreeMem(ibuf, 100000);
  103.       }
  104.       CloseLibrary(XpkBase);
  105.     }
  106.     FreeArgs(rda);
  107.   }
  108. }
  109.  
  110.